package com.example.alibabanacosdiscoveryclient01.service.impl;

import com.example.alibabanacosdiscoveryclient01.entity.BookEntity;
import com.example.alibabanacosdiscoveryclient01.mapper.BookMapper;
import com.example.alibabanacosdiscoveryclient01.service.BookService;
import jakarta.websocket.server.ServerEndpoint;
import org.springframework.ai.chat.model.ToolContext;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:guoq
 * @date:2025/4/28
 * @descripion:
 */
@Service
public class BookServiceImpl implements BookService {
    @Autowired
    BookMapper bookMapper;
    @Override
    @Tool(name = "list",description = "获取图书列表")
    public List<BookEntity> list(@ToolParam(description = "所有图书") String all, ToolContext toolContex) {
        return bookMapper.list();
    }
    @Override
    @Tool(name = "findByName",description = "获取图书列表,支持书名模糊搜索")
    public List<BookEntity> findByName(@ToolParam(description = "书名关键字") String name, ToolContext toolContex) {
        return bookMapper.findByName(name);
    }
    @Override
    @Tool(name = "findByType",description = "获取图书列表,支持分类模糊搜索")
    public List<BookEntity> findByType(@ToolParam(description = "分类关键字") String type,ToolContext toolContex) {
        return bookMapper.findByType(type);
    }
    @Override
    @Tool(name = "findByAuthor",description = "获取图书列表,支持作者模糊搜索")
    public List<BookEntity> findByAuthor(@ToolParam(description = "作者关键字") String author,ToolContext toolContex) {
        return bookMapper.findByAuthor(author);
    }
    @Override
    public int batchInsert(List<BookEntity> list) {
        return bookMapper.batchInsert(list);
    }
}
